package hibernate;

import org.hibernate.Session;


public class GenericRepositry <T , ID>   {

	public  GenericRepositry(){}


	public void Save(T obj) {
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		s.beginTransaction();
		s.save(obj);
		s.getTransaction().commit();
		s.close();
	}

	public void SaveOrUpdate(T obj) {
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		s.beginTransaction();
		s.saveOrUpdate(obj);
		s.getTransaction().commit();		
		s.close();
	}

	public void Update(T obj) {
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		s.beginTransaction();
		s.update(obj);
		s.getTransaction().commit();
		s.close();
	}

	public void Delete(T obj) {	
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		s.beginTransaction();
		s.delete(obj);
		s.getTransaction().commit();
		s.close();
	}

}
